Dynomotion

Group: DynoMotion Message: 9288 From: Toby Rule Date: 3/3/2014
Subject: Deadlocking in KMotion library
Hi Tom, 

I think I previously mentioned that my application sometimes deadlocks in KMotion library calls when the USB cable is unplugged/replugged. I did some more debugging, and found that making the following changes seems to fix the problem.  I'm using KMotion 4.31f. 

1) In KMotionDLL.cpp, in CKMotionDLL::GetStatus, I added "ReleaseToken();" before four occurrence of "return 1;".  Apparently the application sometimes called GetStatus at about the same time the board disconnected, which caused GetStatus to return an error without releasing the token.  

2) in KMotionIO.cpp, in CKMotionIO::ReleaseToken, made the following change.  Apparently, under certain conditions when unplugging / replugging the USB connector, Token became less than zero, which caused KMotionLock to return KMOTION_IN_USE

void CKMotionIO::ReleaseToken()
{
Mutex->Lock();
Token--;
if (Token < 0) Token=0; // ADDED THIS LINE TO ENFORCE Token >= 0
Mutex->Unlock();
}

Regards,

Toby

The information contained in this transmission is intended only for the person or entity
to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive
material. If you are not the intended recipient, please contact the sender immediately
and destroy the material in its entirety, whether electronic or hard copy. You are
notified that any review, retransmission, copying, disclosure, dissemination or other
use of, or taking of any action in reliance upon this information by persons or entities
other than the intended recipient is prohibited.
Group: DynoMotion Message: 9294 From: Tom Kerekes Date: 3/3/2014
Subject: Re: Deadlocking in KMotion library
Hi Toby.

Thank you.  I don't like doing #2 as nothing should Release the Token without obtaining it.  But I can't find a case that is causing it so I guess it is better than a deadlock.  Both changes will be in the next Version.

Regards
TK 


Group: DynoMotion Message: 9296 From: Toby Rule Date: 3/4/2014
Subject: Re: Deadlocking in KMotion library

Thanks Tom.   Sorry I couldn’t get you more info on exactly what was causing issue #2.

 

Toby

 

Group: DynoMotion Message: 9306 From: fireup_kev Date: 3/4/2014
Subject: Re: Deadlocking in KMotion library
Tom,
Can you make an install for version 4.31t with this update. I try to get all the patches for version 4.31s but it would be cleaner if it was one file. Thanks.

Kevin